package com.cloud.controller;

import com.cloud.pojo.sys.Result;
import com.cloud.service.PayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @version v1.0
 * @author: TianXiang
 * @description:
 * @date: 2020/10/21
 */
@RestController
@RequestMapping("/pay")
public class PayController {

    private static final Logger LOG = LoggerFactory.getLogger(PayController.class.getName());

    @Resource
    private PayService payService;

    @GetMapping("/activatePermissions")
    public Result activatePermissions(@RequestParam String cdkey) {
        payService.checkCDKEY(cdkey);
        return Result.createSuccess("激活成功, 请尝试重新登录后进行观影!");
    }

    @GetMapping("/generatorCDKEY")
    public Result generatorCDKEY() {
        int count = payService.generatorCDKEY();
        return Result.createSuccess(String.format("制作卡密 %s 张!", count));
    }

    @GetMapping("/getCDKEY")
    public String getCDKEY() {
        return payService.getCDKEY();
    }

}
